<?php

/**
 * This is the model class for table "tbl_hocvien".
 *
 * The followings are the available columns in table 'tbl_hocvien':
 * @property integer $id
 * @property integer $user_id
 * @property integer $khoahoc_id
 * @property integer $chuyennganh_id
 * @property string $detai_ten
 * @property integer $giaovien_id
 * @property integer $da_dangki_luanvan
 * @property integer $da_chapnhan_dangki
 */
class Hocvien extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Hocvien the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_hocvien';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('user_id, khoahoc_id, chuyennganh_id, detai_ten, giaovien_id', 'required'),
			array('user_id, khoahoc_id, chuyennganh_id, giaovien_id, da_dangki_luanvan, da_chapnhan_dangki', 'numerical', 'integerOnly'=>true),
			array('detai_ten', 'length', 'max'=>500),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, user_id, khoahoc_id, chuyennganh_id, detai_ten, giaovien_id, da_dangki_luanvan, da_chapnhan_dangki', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'user_id' => 'User',
			'khoahoc_id' => 'Khoahoc',
			'chuyennganh_id' => 'Chuyennganh',
			'detai_ten' => 'Detai Ten',
			'giaovien_id' => 'Giaovien',
			'da_dangki_luanvan' => 'Da Dangki Luanvan',
			'da_chapnhan_dangki' => 'Da Chapnhan Dangki',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('khoahoc_id',$this->khoahoc_id);
		$criteria->compare('chuyennganh_id',$this->chuyennganh_id);
		$criteria->compare('detai_ten',$this->detai_ten,true);
		$criteria->compare('giaovien_id',$this->giaovien_id);
		$criteria->compare('da_dangki_luanvan',$this->da_dangki_luanvan);
		$criteria->compare('da_chapnhan_dangki',$this->da_chapnhan_dangki);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}